//
//  LogisticsTableViewCell.m
//  ForestPack
//
//  Created by 郑洲 on 2018/7/20.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "LogisticsTableViewCell.h"
#import "LogisticsMessageModel.h"

@interface LogisticsTableViewCell ()

@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UILabel *statuLabel;
@property (nonatomic, strong) UILabel *addressLabel;
@property (nonatomic, strong) UIView *line;
@property (nonatomic, strong) UIImageView *noteIcon;
@property (nonatomic, strong) NSString *time;
@end

@implementation LogisticsTableViewCell

+ (LogisticsTableViewCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"LogisticsTableViewCell";
    LogisticsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[LogisticsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {
    self.line = [[UIView alloc] initWithFrame:CGRectMake(ScreenX375(78.5), 0, 1, ScreenX375(75))];
    self.line.backgroundColor = REXADECIMALCOLOR(@"#efefef");
    [self addSubview:self.line];
    
    self.noteIcon = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(73), 0, ScreenX375(15), ScreenX375(15))];
    self.noteIcon.image = ImageWithName(@"物流Note");
    [self addSubview:self.noteIcon];
    
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(15), 0, ScreenX375(43), ScreenX375(28))];
    self.timeLabel.numberOfLines = 3;
    self.timeLabel.textAlignment = NSTextAlignmentRight;
    self.timeLabel.font = Kfont(14);
    [self addSubview:self.timeLabel];
    
    self.statuLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(103), 0, ScreenX375(245), ScreenX375(14))];
    self.statuLabel.text = @"已签收";
    self.statuLabel.font = Kfont(14);
    [self addSubview:self.statuLabel];
    
    self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(103), ScreenX375(25), ScreenX375(245), ScreenX375(36))];
    self.addressLabel.text = @"[收货地址]在广东区白云石转送在广东区在广东区白云石转送在广东区白云石转送在";
    self.addressLabel.numberOfLines = 0;
    self.addressLabel.font = Kfont(12);
    [self addSubview:self.addressLabel];
}

- (void)setStatu:(BOOL)isNow {
    if (isNow) {
        self.timeLabel.textColor = FONTCOLOR_BLACK;
        self.addressLabel.textColor = FONTCOLOR_BLACK;
        self.noteIcon.image = ImageWithName(@"物流");
    }else {
        self.timeLabel.textColor = FONTCOLOR_LIGHTGRAY;
        self.addressLabel.textColor = FONTCOLOR_LIGHTGRAY;
        self.noteIcon.image = ImageWithName(@"物流");
    }
}

-(void)initWithModel:(LogisticsMessageModel *)model{
    self.addressLabel.text = model.AcceptStation;
    self.time = model.AcceptTime;
    NSString *time1 = [self.time substringWithRange:NSMakeRange(5, 11)];
    NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc]initWithString:time1];
    [attributedStr addAttribute:NSFontAttributeName value:Kfont(9) range:NSMakeRange(5,time1.length - 5)];
    self.timeLabel.attributedText = attributedStr;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
